﻿
namespace HAVNet.Intros.AST
{
    class Mods
    {
        public const long
          newMod = 0x0001, publicMod = 0x0002, protectedMod = 0x0004, internalMod = 0x0008,
          privateMod = 0x0010, unsafeMod = 0x0020, staticMod = 0x0040, readonlyMod = 0x0080,
          volatileMod = 0x0100, virtualMod = 0x0200, sealedMod = 0x0400, overrideMod = 0x0800,
          abstractMod = 0x1000, externMod = 0x2000,

          /* sets of modifiers that can be attached to certain program elements    *
           * e.g., "constants" marks all modifiers that may be used with constants */
          noneMod = 0x0000,
          classesMod            = newMod | publicMod | protectedMod | internalMod | privateMod | unsafeMod | abstractMod | sealedMod | staticMod,
          constantsMod          = newMod | publicMod | protectedMod | internalMod | privateMod,
          fieldsMod             = newMod | publicMod | protectedMod | internalMod | privateMod | unsafeMod | staticMod | readonlyMod | volatileMod,
          propEvntMethsMod      = newMod | publicMod | protectedMod | internalMod | privateMod | unsafeMod | staticMod | virtualMod | sealedMod | overrideMod | abstractMod | externMod,
          accessorsPossib1Mod   = privateMod,
          accessorsPossib2Mod   = protectedMod | internalMod,
          indexersMod           = newMod | publicMod | protectedMod | internalMod | privateMod | unsafeMod | virtualMod | sealedMod | overrideMod | abstractMod | externMod,
          operatorsMod          = publicMod | unsafeMod | staticMod | externMod,
          operatorsMustMod      = publicMod | staticMod,
          constructorsMod       = publicMod | protectedMod | internalMod | privateMod | unsafeMod | externMod,
          staticConstrMod       = externMod | staticMod,
          staticConstrMustMod   = staticMod,
          nonClassTypesMod      = newMod | publicMod | protectedMod | internalMod | privateMod | unsafeMod,
          destructorsMod        = externMod | unsafeMod,
          allMod                = 0x3fff;

        public static bool has (long val, long mod)
        {
            return mod == (val & mod);
        }
    }
}
